package com.tencent.examples.blueking.mongo.repository;

import com.tencent.examples.blueking.mongo.model.ObjAttDes;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.query.QueryByExampleExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ObjAttDesRepository extends MongoRepository<ObjAttDes, String>, QueryByExampleExecutor<ObjAttDes> {

    @Query(value = "{" +
            "    bk_obj_id:?0,\n" +
            "    bk_property_id:?1,\n" +
            "    bk_property_type:?2\n" +
            "}")
    List<ObjAttDes> findEnum(String bk_obj_id, String bk_property_id, String bk_property_type);

    @Query(value = "{" +
            "    bk_obj_id:?0,\n" +
            "}")
    List<ObjAttDes> getMdzInfo(String bk_obj_id);


    @Query(value = "{" +
            "    bk_property_id:?2,\n" +
            "    bk_obj_id:?0,\n" +
            "    option:{$elemMatch:{id:?1}}\n" +
            "}")
    List<ObjAttDes> findEnumValue(String bk_obj_id, String id, String bk_property_id);
}
